<template>
  <div class="xtx-wrapper">
    <div class="container">
      <h3 class="title">一站买全，编辑精心整理优选推荐</h3>
      <div v-for="item in list" :key="item">
        <!-- 背景标题 -->
        <div class="xtx-bg-title" :style="{backgroundImage:`url(${item.picture})`}">
          <h4>{{item.name}}</h4>
          <p>{{item.summary}}</p>
        </div>
        <!-- 小图商品 -->
        <div class="xtx-mini-product">
          <ul class="clearfix">
            <li
              v-for="item in item.goods"
              :key="item.id"
              @click="$router.push(`/product/${item.id}`)"
            >
              <img :src="item.picture" alt="" />
              <p class="tit ellipsis">{{ item.name }}</p>
              <p class="desc ellipsis">{{ item.desc }}</p>
              <p class="price">¥{{ item.price }}</p>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'One',
  data () {
    return {
      list: []
    }
  },
  created () {
    this.$http.get('/home/oneStop').then((res) => {
      this.list = res.data.result
    })
  }
}
</script>

<style scoped lang='less'>
// 布局容器
.xtx-wrapper {
  background: #f5f5f5;
  line-height: 1.4;
  .container {
    width: 1240px;
    margin: 0 auto;
    .title {
      height: 215px;
      line-height: 215px;
      font-size: 32px;
      text-align: center;
      font-weight: normal;
    }
  }
}
// 背景标题
.xtx-bg-title {
  width: 100%;
  height: 180px;
  padding-left: 213px;
  background: no-repeat center / cover;
  h4 {
    padding-top: 52px;
    font-size: 32px;
    font-weight: bold;
  }
  p {
    padding-top: 5px;
    font-size: 20px;
  }
}

// 小图商品
.xtx-mini-product {
  padding-top: 40px;
  padding-bottom: 20px;
  ul {
    li {
      width: 232px;
      height: 320px;
      float: left;
      background: white;
      margin-right: 20px;
      text-align: center;
      margin-bottom: 20px;
      &:nth-child(5n) {
        margin-right: 0;
      }
      img {
        width: 212px;
        height: 212px;
        display: block;
        margin: 10px;
        transition: all .5s;
        &:hover {
          transform: scale(1.05);
        }
      }
      p {
        padding: 0 20px;
      }
      .tit {
        padding-top: 4px;
        font-size: 16px;
      }
      .desc {
        padding-top: 4px;
        color: #999;
      }
      .price {
        font-size: 18px;
        color: @priceColor;
        padding-top: 6px;
      }
    }
  }
}

// - 简易标题 -
.xtx-simpla-title {
  height: 40px;
  font-size: 28px;
  text-align: center;
}

// 大图品牌
.xtx-large-brand {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  .item {
    width: 610px;
    height: 480px;
    background: white;
    margin-bottom: 40px;
    img {
      width: 100%;
      height: 320px;
      display: block;
    }
    .info {
      padding: 0 35px;
      position: relative;
      p {
        &.name {
          padding-top: 22px;
          padding-bottom: 12px;
          font-size: 20px;
          i {
            width: 36px;
            height: 18px;
            line-height: 18px;
            background: @xtxColor;
            border-radius: 2px;
            color: #fff;
            font-size: 14px;
            display: inline-block;
            text-align: center;
          }
        }
        &.desc {
          color: #999;
          font-size: 14px;
          height: 40px;
          line-height: 20px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          padding-right: 40px;
        }
      }
      .price {
        position: absolute;
        top: 20px;
        right: 35px;
        color: @priceColor;
        font-size: 18px;
      }
    }
    .comment {
      padding: 15px 35px 0;
      line-height: 40px;
      color: #999;
      .line {
        width: 100%;
        height: 1px;
        background: #e4e4e4;
      }
      .red {
        color: @priceColor;
      }
      .mr18 {
        margin-right: 18px;
      }
    }
  }
}
</style>
